With convergence of communications networks, intercommunication and interconnection between an optical transport network and an IP network, as well as other networks, are widely applied. When functioning as a physical layer network of a network of another type, an optical transport network must encapsulate data of the network of another type in a certain format, and the most common encapsulation form is GFP (Generic framing procedure, generic framing procedure) encapsulation.
Common GFP encapsulation is often applied to 1 G-10 G low rate code streams. Therefore, the maximum bit width of encapsulated data is 64 bits. However, with rapid development of networks, encapsulated data streams range from 40 G to 200 G and the data bit width then changes to range from 128 bits to 512 bits. As regards these data streams with large bit widths, a plurality of data frames may be encapsulated within a clock cycle. For example, when a data stream has a bit width of 521 bits, data of each clock cycle is 512/8=64 bytes, and usually the length of a GFP frame is 12 bytes, so that five data frames may be encapsulated within a clock cycle.
In the prior art, a method for performing a frame location on a GFP frame encapsulated within a clock cycle is: adopting a framing state machine to perform a hunt on a data stream within a current clock cycle byte by byte, and determine a starting byte of a header of a GFP frame. The framing state machine includes three states, which respectively are: a HUNT (hunt) state, a PRESYNC (preliminary synchronization) state, and a SYNC (synchronization) state.
The framing state machine is in the HUNT state when a hunt starts, and starts the hunt from a first byte of the data stream in the current clock cycle. After a byte conforming to features of a header of a first GFP frame is hunted out, the state of the framing state machine changes to the PRESYNC state. Then, according to length information of the GFP frame carried in the byte conforming to the features of the header of the GFP frame, the framing state machine hunts out a starting byte of a header of a second GFP frame. After authentication on the starting byte of the header of the GFP frame succeeds, the state of the framing state machine changes to the SYNC state. The framing state machine determines that the starting bytes of the header of the first GFP frame and the header of the second GFP frame are correct, and records the starting bytes of the header of the first GFP frame and the header of the second GFP frame and lengths of the frames in the hunt result. Then, the framing state machine continues the hunt from the starting byte of the header of the second GFP frame until a set hunt period corresponding to the current clock cycle ends.
When the framing state machine is in the PRESYNC state or SYNC state, if the starting byte of the header of the second GFP frame is hunted out, but authentication on the starting byte fails, the framing state machine changes to the HUNT state.
In the implementation of the present invention, the inventor finds that the method for performing a frame location on a GFP frame encapsulated within a clock cycle in the prior art at least has the following problem: since the period of a clock cycle is very short, the set hunt period corresponding to the current clock cycle is also very short. The framing state machine starts the hunt from the first byte of the data stream within the current clock cycle. If the first byte is not the starting byte of the GFP frame, and when a plurality of data frames are encapsulated within the current clock cycle, the method may fail to hunt out a correct starting byte of the GFP frame, and as a result, cannot locate a GFP frame encapsulated in the data stream within the current clock cycle.